home *** CD-ROM | disk | FTP | other *** search
- Path: bmtlh10.bnr.ca!news
- From: John Hickin <hickin@bnr.ca>
- Newsgroups: comp.lang.c++
- Subject: Re: Compile problem
- Date: 1 Feb 1996 14:58:58 GMT
- Organization: Bell-Northern Research
- Message-ID: <4eqkfi$fl8@bmtlh10.bnr.ca>
- References: <4eol9k$gqf@fred.uswnvg.com>
- NNTP-Posting-Host: bmtlh520.bnr.ca
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1 (X11; I; HP-UX A.09.05 9000/715)
- X-URL: news:4eol9k$gqf@fred.uswnvg.com
-
- This happens with gotos and often happens in switch statements which are
- disguised gotos. Essentially the compiler has determined that you are using an
- object without having constructed it. Consider the following:
-
- switch(type)
- { case 1: int x = 1; ...
- case 2: ++x;
- etc.
- }
-
- and watch what happens if type != 1.
-
- One solution uses a separate block for each case:
-
- case 1: { int x = 1; ... }
-
- The other 'promotes' the scope of x (define it before the switch). Which
- one you use depends whether or not x must be accessed by more than one case.
-
- --
- John Hickin Bell-Northern Research, Montreal, Quebec
- (514) 765-7924 hickin@bnr.ca
-
-